<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
    <style type="text/css">
        body {
            background: rgba(190, 190, 190, 0.3);
        }

        .big-box {
            background: #fff;
            border-radius: 20px;
            width: 223px;
            /*height: 215px;*/
            position: absolute;
            left: 50%;
            top: 42%;
            transform: translate(-50%, -50%);
            padding-top: 15px;
        }

        .pricenumber {
            font-size: 13px;
            padding-left: 15px;
            padding-right: 15px;
            padding-top: 13px;
        }

        .buyvideo {
            font-size: 13px;
            border-top: 1px solid #8F8F8F;
            color: #ED7C4C;
            text-align: center;
            height: 35;
            line-height: 35px;
        }

        .hua {
            height: 1px;
            background-color: #000;
            width: 87%;
            top:22px;
            position: absolute;
        }
    </style>
</head>

<body>
    <div class="big-box" id="vm" v-cloak>
        <div style="text-align:center;color:#8F8F8F;font-size:16px">购买视频</div>

        <div class="pricenumber">价格：<span>{{videovipcash}}元</span></div>
        <div class="pricenumber" style="position:relative">
            <div class="hua"></div>
            原价：<span>{{videocash}}元</span>
        </div>
        <div class="pricenumber">观看有效期至{{riqi}}</div>
        <div class="pricenumber" style="padding-bottom:13px;">官方有权调整影片内容</div>
        <div class="buyvideo" onclick="Buy()">{{videovipcash}}元购买</div>
        <div class="buyvideo" onclick="Opencancel()">取消</div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script type="text/javascript" src="../../script/vue.2.5.js"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/rest.js"></script>
<script type="text/javascript" src="../../script/faskclick.js"></script>
<script type="text/javascript">
    var uid = $api.getStorage('uid');

    var vm = new Vue({
        el: '#vm',
        data: {
            videocash: '',
            videovipcash: '',
            videoid: '',
            riqi: '',
        },
        created: function() {
            var _this = this;

            apiready = function() {
                _this.init();
                api.parseTapmode();
                if ('addEventListener' in document) {
                    document.addEventListener('DOMContentLoaded', function() {
                        FastClick.attach(document.body);
                    }, false);
                }

            }
        },
        methods: {
            init: function() {
                var _this = this;
                _this.videoid = api.pageParam.videoid;
                _this.videocash = api.pageParam.videocash;
                _this.videovipcash = api.pageParam.videovipcash;
                _this.riqi = api.pageParam.riqi.split(' ')[0];
                if (api.pageParam.isyongjiu==1) {
                    _this.riqi = '永久'
                }
                // var data1 = {
                //     video_id: _this.videoid,
                //     uid: uid
                // }
                // new rest().get('getDetail').datae(data1).success(function(res) {
                //     console.log(JSON.stringify(res))
                //     if (res.flag == 1) {
                //         _this.videodetial = res.msg;
                //         _this.videocash=_this.videodetial.video_free_cash;
                //         _this.videovipcash=_this.videodetial.video_vip_cash;
                //         _this.riqi=_this.videodetial.endtime.split(' ')[0];
                //     }
                // }).error(function(err) {
                //     console.log(JSON.stringify(err))
                // }).run()

            }

        }
    })

    function Opencancel() {
      if (api.pageParam.value==1) {
          api.sendEvent({
              name: 'playvideoad'
          });
          // setTimeout(function() {
            api.closeFrame();
          // }, 1000)
      }else {
          api.sendEvent({
              name: 'bofang'
          });
          // setTimeout(function() {
            api.closeFrame();
          // }, 1000)
      }
    }

    function Buy() {
      uid=$api.getStorage('uid');
        if (uid) {
            if (vm.videovipcash == 0) {
                api.toast({
                    msg: '视频价格为0元',
                    duration: 2000,
                    location: 'bottom'
                });
                api.sendEvent({
                    name: 'keguankanguanbi'
                });
                api.sendEvent({
                    name: 'goumaiwan'
                });
                if (api.pageParam.value==1) {
                    api.sendEvent({
                        name: 'playvideoad'
                    });
                    setTimeout(function() {
                      api.closeFrame();
                    }, 1000)
                }else {
                    api.sendEvent({
                        name: 'bofang'
                    });
                    setTimeout(function() {
                      api.closeFrame();
                    }, 1000)
                }

            } else {
                api.openFrame({
                    name: 'wechatpay',
                    url: '../wechatpay.html',
                    rect: {
                        x: 0,
                        y: 0,
                        w: 'auto',
                        h: 'auto'
                    },
                    pageParam: {
                        videocash: vm.videovipcash,
                        videoid: vm.videoid,
                        value:api.pageParam.value
                    },
                    bounces: false,
                    bgColor: 'rgba(0,0,0,0)',
                    vScrollBarEnabled: true,
                    hScrollBarEnabled: true
                });
            }

        } else {
            api.openFrame({
                name: 'login_introduction',
                url: '../myself/login_introduction.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
                bounces: false,
                bgColor: 'rgba(0,0,0,0.7)',
                vScrollBarEnabled: true,
                hScrollBarEnabled: true
            });
        }



        setTimeout(function() {
            api.closeFrame();
        }, 200)

    }
</script>

</html>
